<template>
	<view class="content">
		<view class="item" v-for="(item,index) in list" :key="index" @click="toDetail(item)">
			<view class="item_title">
				<text>{{item.name}}</text>
				<view class="item_status">
					<img src="/static/images/applying.png" alt="" mode="widthFix" v-if="item.enum=='申请中'">
					<img src="/static/images/approve.png" alt="" mode="widthFix" v-if="item.enum=='已通过'">
					<img src="/static/images/reject.png" alt="" mode="widthFix" v-if="item.enum=='已拒绝'">
				</view>
			</view>
			<view class="item_info">
				事项:{{item.subtitle}}
			</view>
			<view class="item_time">
				{{item.create_time_text}}
			</view>
		</view>
		<view style="text-align: center;">
			<u-loadmore :status="status" :loading-text="loadingText"  :loadmore-text="loadmoreText"  :nomore-text="nomoreText"/>
		</view>
	</view>
</template>

<script>
	import {applylist} from '@/api/api.js'
	export default {
		data() {
			return {
				list:[],
				page: 0,
				size:10,
				total:0,
				status:'loadmore',
				 loadingText: '正在拼命加载中',
				loadmoreText: '轻轻上拉',
				nomoreText: '没有更多了~'
			}
		},
		onLoad() {
			this.getApplylist()
		},
		onReachBottom(){
			this.getApplylist()
		},
		methods: {
			getApplylist(){
				if(this.status == 'nomore'){
					return
				}
				this.page++
				this.status = 'loading'
				applylist({page:this.page}).then(res=>{
					this.list.push(...res.data.data)
					this.total = res.data.total
					if(this.total <= this.list.length){
						this.status = 'nomore'
					}else {
						this.status = 'loadmore'
					}
				})
			},
			toDetail(item){
				// 有预约按钮 肯定不是服务商和供应商，这里pid不传也可以
				uni.navigateTo({
					url:'/pages/product/detail?id=' + item.article_id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 0 32rpx;
	}
	.item {
		margin-top: 20rpx;
		background-color: #fff;
		border-radius: 16rpx;
		padding: 30rpx;
		&_title {
			font-size: 32rpx;
			font-weight: 600;
			color: #333333;
			line-height: 40rpx;
			display: flex;
			align-items: center;
		}
		&_status{
			width: 76rpx;
			height: 36rpx;
			margin-left: 16rpx;
			img{
				width: 100%;
			}
		}
		&_info {
			margin-top: 18rpx;
			font-size: 28rpx;
			font-weight: 400;
			color: #666666;
			line-height: 40rpx;
		}
		&_time {
			margin-top: 10rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: #999999;
			line-height: 52rpx;
		}
	}

</style>
